package com.hmsm.sys.daoImpl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.stereotype.Repository;

import com.hmsm.server.base.BaseDao;
import com.hmsm.sys.dao.UserOrgDao;
import com.hmsm.sys.po.UserOrg;

@Repository
public class UserOrgDaoImpl extends BaseDao<UserOrg, Integer> implements UserOrgDao {
	
	/**
	 * 根据部门ID获取关联信息
	 * @param deptId
	 * @return
	 * @author 何杰 2013-2-21
	 */
	@SuppressWarnings("unchecked")
	public List<UserOrg> getUserOrgListByDeptId(final int deptId){
		return (List<UserOrg>) getHibernateTemplate().execute(new HibernateCallback(){
			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
				return session.createCriteria(UserOrg.class)
								.add(Restrictions.eq("deptId", deptId))
								.list();
			}
		});
		
	}
}
